import Vue from 'vue'
import Vuex from 'vuex'
import router from './router.js';

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		token: '',
		webconfig: {},
		userInfo: {}
	},
	getters: {
		getToken: state => {
			return state.token || window.localStorage.getItem("token")
		},
		getWebConfig: state => {
			return state.webconfig || JSON.parse(window.localStorage.getItem('webconfig'));
		},
		getUserInfo: state => {
			return state.userInfo || JSON.parse(window.localStorage.getItem('userInfo'));
		}
	},
	mutations: {
		setToken: (state, data) => {
			console.log(data)
			state.token = data;
			console.log("setToken", data)
			window.localStorage.setItem("token", data)
			// state.token = "EE64-F84C-5E0F-763E";
		},
		setWebConfig: (state, data) => {
			console.log(data)
			window.localStorage.setItem("webconfig", JSON.stringify(data))
			state.webconfig = data;
		},
		setUserInfo: (state, data) => {
			console.log(data)
			window.localStorage.setItem("userInfo", JSON.stringify(data))
			state.userInfo = data;
		}
	},
	actions: {

	}
})
